import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [{
  path: '/',
  redirect: '/home',
  component: () => import('@/views/layout'),
  children: [{
    path: '/home',
    component: () => import('@/views/home')
  },
  {
    path: '/video',
    component: () => import('@/views/video')
  },
  {
    path: '/qa',
    component: () => import('@/views/qa')
  },
  {
    path: '/my',
    component: () => import('@/views/my')
  },
  {
    path: '/search',
    component: () => import('@/views/search')
  }
  ]
},
{
  path: '/login',
  name: 'login',
  component: () => import('@/views/login')
},
{
  path: '/article/:articleId',
  name: 'article',
  component: () => import('@/views/article'),
  props: true // 开启 Props 传参，说白了就是把路由参数映射到组件的 props 数据中
},
{
  path: '/user/profile',
  component: () => import('@/views/user/index.vue')
}
]

const router = new VueRouter({
  routes
})

export default router
